<?php
/**
 * Created by PhpStorm.
 * User: yuyang
 * Date: 14-1-3
 * Time: 上午10:36
 */

class RssController extends Controller {
    function index(){
        include_once COMMON.DS."Constant.class.php";
        $pagesets = Constant::indexHeader();

        //设置表头
        header('Content-Type:application/xml;charset=utf-8');
        $this->getSmarty();
        $dbutil = $this->getDB();
        $this->smarty->assign("webtitle",$pagesets["seo"]["title"]);//网站标题
        $this->smarty->assign("desc",$pagesets["seo"]["description"]);//网站标题
        $this->smarty->assign("weburl",WEBSITE_URL);//网站地址
        $this->smarty->assign("pubdate",date('Y-m-d H:i:s',time()));//发布日期
        //得到最后发布文章的日期
        $datasql = "select post_date from posts  where post_status=0  order by post_date  desc    LIMIT 1";
        $lastpostdate = $dbutil->get_row($datasql);
        $this->smarty->assign("lastdate",$lastpostdate->post_date);//最后文章的时间

        $datasql = "select post_title,post_category,post_excerpt,post_date,category_name from posts ,post_category where post_status=0 and posts.post_category = post_category.category_id order by post_date  desc    LIMIT 0,20";
        $postdata = $dbutil->get_results($datasql);
        require_once SERVICE . DS . 'IndexService.class.php';
        $indexService = new IndexService( $this->getDB () );
        $indexService->fillPostHref($postdata);
        $this->smarty->assign("postdata",$postdata);//数据
        $this->smarty->display("rss.xml");
        ob_end_flush();
    }
}
